package com.ui;

import javax.swing.*;
import java.awt.event.*;

public class Usr_ui extends JDialog {
    private JPanel contentPane;
    private JButton buttonOK;
    private JButton buttonCancel;
    private JButton 修改密码Button;
    private JButton 购买记录Button;
    private JButton 余额查询Button;
    private JButton Button_cart;
    private JButton 退货换货Button;
    private JButton 账户充值Button;

    public Usr_ui() {
        setContentPane(contentPane);
        setModal(true);
        getRootPane().setDefaultButton(buttonOK);

        buttonOK.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                onOK();
            }
        });

        buttonCancel.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                onCancel();
            }
        });

        // 点击 X 时调用 onCancel()
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                onCancel();
            }
        });

        // 遇到 ESCAPE 时调用 onCancel()
        contentPane.registerKeyboardAction(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                onCancel();
            }
        }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        Button_cart.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                ONcart();
            }
        });
        购买记录Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                ONpurhistory();
            }
        });
        余额查询Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                onpac_usr();
            }
        });
        账户充值Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                ontochongzhi();
            }
        });
        退货换货Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                ontotuihuan();
            }
        });
        修改密码Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                ontopasw();
            }
        });
    }
    private void ontopasw(){
        new Chage_pasw().main();
    }
    private void ontotuihuan(){new TuiHuan().main();}
    private void ontochongzhi(){
        new Pac_usrchongzhi().main();
    }
    private void onpac_usr(){
        new Pac_usr().main();
    }
    private void ONpurhistory(){
        new pur_history().main();
    }
    private void ONcart(){
        new Cart().main();
    }
    private void onOK() {
        // 在此处添加您的代码
        dispose();
    }

    private void onCancel() {
        // 必要时在此处添加您的代码
        dispose();
    }

    public void main() {
        Usr_ui dialog = new Usr_ui();
        dialog.pack();
        dialog.setVisible(true);
        //System.exit(0);
    }
}
